//
//  NewHomeInfoCell.m
//  GC_OC
//
//  Created by  Quan He on 2022/4/9.
//

#import "NewHomeInfoCell.h"
@interface NewHomeInfoCell ()


@end

@implementation NewHomeInfoCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initUI];
        _model = [[CurriculumModel alloc] init];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    _isshow = NO;
    [self initUI];
    _model = [[CurriculumModel alloc] init];
}

- (void)setModel:(CurriculumModel *)model {
    _model = model;
    NSString* str = [GC_OCTool timeStrWithSecTime:[model.audio_num integerValue]];
//    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.image]];
    [self.coverImageView  sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageNamed:@"default"]];

    self.titleLabel.text = model.name;

    self.infoLabel.text = model.describe;

    self.timeLabel.text = str;
    
    if (model.describe.length > 0) {
        self.topSpace.constant = 2;
    } else {
        self.topSpace.constant = 25;
    }
    
    if (model.isShow) {
        [self forinBackgroundColor:self.contentView];
    }else{
        [self forinBackgroundwhiteColor:self.contentView];
    }
    
//    _coverImageView.backgroundColor = [UIColor redColor];
//
//    _titleLabel.backgroundColor = [UIColor yellowColor];
}

-(void)setIsshow:(BOOL)isshow{
    _isshow = isshow;
//    if (_isshow) {
//        [self forinBackgroundColor:self.contentView];
//    }else{
//        [self forinBackgroundwhiteColor:self.contentView];
//    }
}

-(void)forinBackgroundColor:(UIView *)view{
    for (UIView *v in view.subviews) {
        v.backgroundColor = [UIColor colorWithRed:245/255.0 green:251/255.0 blue:1 alpha:1];
        [self forinBackgroundColor:v];
    }
}

-(void)forinBackgroundwhiteColor:(UIView *)view{
    for (UIView *v in view.subviews) {
        v.backgroundColor = [UIColor whiteColor];
        [self forinBackgroundwhiteColor:v];
    }
}

- (void)initUI {
    self.contentView.backgroundColor = [UIColor colorWithRed:0.96 green:0.97 blue:0.98 alpha:1.00];
//    self.backgroundColor = [UIColor colorWithRed:0.96 green:0.97 blue:0.98 alpha:1.00];
//    self.contentView.backgroundColor = [UIColor redColor];
//    self.backgroundColor = [UIColor blueColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.coverImageView.layer.masksToBounds = YES;
    self.coverImageView.layer.cornerRadius = 12;
}

@end
